#pragma once
#include <iostream>
using namespace std;
#ifndef _FUN_H_  
#define _FUN_H_  

char *strcat1(char *str1, char *str2) {
	int len1 = 0;
	int len2 = 0;
	char *str;
	if (str1 == NULL&&str2 == NULL) {
		return "";
	}
	else if (str1 == NULL&&str2) {
		while (str2[len2]) {
			++len2;
		}

		++len2;
		str = (char *)malloc(sizeof(char)*(len2));
		for (int i = 0; i < len2; ++i) {
			str[i] = str2[i];
		}

	}
	else if (str1&&str2 == NULL) {
		while (str1[len1]) {
			++len1;
		}

		++len1;
		str = (char *)malloc(sizeof(char)*(len1));
		for (int i = 0; i < len1; ++i) {
			str[i] = str1[i];
		}

	}
	else {
		while (str1[len1]) {
			++len1;
		}
		++len1;

		while (str2[len2]) {
			++len2;
		}

		str = (char *)malloc(sizeof(char)*(len1 + len2));

		for (int i = 0; i < len1 + len2; ++i) {
			if (i < (len1 - 1)) {
				str[i] = str1[i];
			}
			else {
				str[i] = str2[i - len1 + 1];
			}

		}


		str[(len1 + len2)] = '\n';
	}

	return str;
}


#endif//_FOO_H_
